# ** Header **
import types

# ** Body **
class exposed(type):
    """
        Iterates over each attribute of a class and exposes it if all of the following
        conditions are true:
         * Attribute is a method
         * Methods name has no "_" prefix (i.e. def _superPrivateCode())
         * Method has docstrings (not implemented yet)

        Set this class as a metaclass to get the effect working:
            >>> class MyClass:
            ...    __metaclass__ = exposed
            ...    [ ... ]
            >>>

        To be exposed means that CherryPy will publish a method for HTTP requests.
    """
    def __init__(cls, name, bases, dict):
        super(exposed, cls).__init__(name, bases, dict)
        for name, value in dict.iteritems():
            if type(value) == types.FunctionType and not name.startswith("_"):
                value.exposed = True

# ** Footer **
